package top.kaoshanji.p1ch03b;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 代码清单 p1ch03b-05：Path接口的使用示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/10 20:19
 */
public class PathExample01 {

    private static final Logger logger = LogManager.getLogger(PathExample01.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch03b-05：Path接口的使用示例...");

        Path path1 = Paths.get("folder1", "sub1");
        Path path2 = Paths.get("folder2", "sub2");

        System.out.println(path1.resolve(path2));

        System.out.println(path1.resolveSibling(path2));
        System.out.println(path1.relativize(path2));
        System.out.println(path1.subpath(0, 1));
        System.out.println(path1.startsWith(path2));
        System.out.println(path1.endsWith(path2));

        System.out.println(Paths.get("folder1/./../folder2/my.text").normalize());
    }


}
